#include <stdio.h>
#include <stdlib.h>
#include "commons.h"
#include "load_data.h"
#include "landmarks.h"

float rand_float(float min_val, float max_val){
	float value;
	value = min_val + ((float) rand() / RAND_MAX) * (max_val - min_val);
	return value;
}

int rand_int(int min_val, int max_val){
	return (int) (rand_float((float) min_val, (float) max_val));
}



EXPORT float *loadSamples(int num_samples, int dimension, float radius)
{
	int i;
	float *samples;
	samples = (float*) malloc_align(num_samples * dimension * sizeof(float),7);

	srand( time(NULL) );

 
	for(i = 0; i < num_samples*dimension; i++){
		samples[i] = rand_float(-radius,radius);
	}

	return samples;
}

EXPORT void *initLandmarks(float *data, int *freeList, int num_landmarks_to_init, int dimension, float radius)
{
    int i,j;
	float *l;	
	
	l = (float*) malloc(dimension*sizeof(float));	

	fprintf(stderr,"%d %d\n",num_landmarks_to_init,dimension);
    for(i = 0; i < num_landmarks_to_init; i++){
    	for(j=0;j<dimension;j++){
			l[j] = rand_float(-radius,radius);
    	}
		landmarks_newLandmark(l,data,num_landmarks_to_init,freeList);
	}

}

